import { getCssVariableValue } from '@/utils/utils';

export const SELECT_DATA = ['交易单元', '日期', '时点'];
export const OPTION_KEY = {
  交易单元: 'unit',
  日期: 'date',
  时点: 'timeOrder',
};

export const UNIT_TYPE_OPTIONS = [
  { label: '全部', value: 0 },
  { label: '风电', value: 3 },
  { label: '光伏', value: 4 },
];
export const operators = {
  综合收入: { total: 'sum', point: 'any' },
  综合电量: { total: 'sum', point: 'any' },
  综合电价: { total: 'custom', point: 'any' },
  合约比例: { total: 'custom', point: 'custom' },
  电能电费: { total: 'sum', point: 'any' },
  电能电价: { total: 'custom', point: 'any' },
  中长期价差结算电费: { total: 'sum', point: 'any' },
  中长期电量: { total: 'sum', point: 'any' },
  中长期电价: { total: 'custom', point: 'any' },
  用户侧结算参考点电价: { total: 'custom', point: 'any' },
  现货电费: { total: 'sum', point: 'any' },
  计量电量: { total: 'sum', point: 'any' },
  实时节点电价: { total: 'custom', point: 'any' },
  回收费用: { total: 'sum', point: 'any' },
  补偿费用: { total: 'sum', point: 'any' },
  中长期电费: { total: 'sum', point: 'any' },
};

export const headerMap = {
  电能电费: 'comprehensiveElectricityBill',
  电能电价: 'energyPrice',
  综合电量: 'synthesizeQuantity',
  综合电价: 'synthesizeElectrovalence',
  中长期价差结算电费: 'mediumAndLongPower',
  中长期电量: 'mediumAndLongQuantity',
  中长期电价: 'mediumAndLongElectrovalence',
  用户侧结算参考点电价: 'wholeNetworkElectrovalence',
  现货电费: 'spotGoodsPower',
  计量电量: 'spotGoodsQuantity',
  实时节点电价: 'spotGoodsElectrovalence',
  结算均价: 'settlementAveragePrice',
  合约均价: 'averageContractPrice',
  回收费用: 'recoveries',
  补偿费用: 'compensationExpenses',
  综合收入: 'comprehensiveIncome',
  合约比例: 'contractRatio',
  中长期电费: 'mediumAndLongIncome',
};

export const CODE1 = 'title';

export const columns = [
  {
    name: '',
    align: 'left',
    code: CODE1,
    width: 130,
    lock: true,
  },
  {
    name: '综合统计',
    children: [
      {
        name: '综合收入',
        code: 'comprehensiveIncome',
      },
      {
        name: '综合电量',
        code: 'synthesizeQuantity',
      },
      {
        name: '综合电价',
        code: 'synthesizeElectrovalence',
      },
      {
        name: '合约比例',
        code: 'contractRatio',
      },
    ],
  },
  {
    name: '电费统计',
    children: [
      {
        name: '电能电费',
        code: 'comprehensiveElectricityBill',
      },
      {
        name: '电能电价',
        code: 'energyPrice',
      },
    ],
  },
  {
    name: '中长期统计',
    children: [
      {
        name: '中长期价差结算电费',
        code: 'mediumAndLongPower',
      },
      {
        name: '中长期电量',
        code: 'mediumAndLongQuantity',
      },
      {
        name: '中长期电价',
        code: 'mediumAndLongElectrovalence',
      },
      {
        name: '用户侧结算参考点电价',
        code: 'wholeNetworkElectrovalence',
      },
    ],
  },
  {
    name: '现货统计',
    children: [
      {
        name: '现货电费',
        code: 'spotGoodsPower',
      },
      {
        name: '计量电量',
        code: 'spotGoodsQuantity',
      },
      {
        name: '实时节点电价',
        code: 'spotGoodsElectrovalence',
      },
    ],
  },
  {
    name: '回收及补偿费用',
    children: [
      {
        name: '回收费用',
        code: 'recoveries',
      },
      {
        name: '补偿费用',
        code: 'compensationExpenses',
      },
    ],
  },
].map((t) => ({
  ...t,
  align: t.align || 'center',
  render: t.render ?? ((v) => v ?? '-'),
  children: t.children?.map((c) => ({
    ...c,
    align: 'center',
    render: c.render ?? ((v) => v ?? '-'),
    width: 100,
    features: {
      sortable: true,
    },
  })),
}));

export const seriseMap = {
  synthesizeQuantity: {
    name: '综合电量',
    type: 'bar',
    color: '#18A0FB',
    props: {
      barCategoryGap: 0,
    },
  },
  synthesizeElectrovalence: {
    name: '综合电价',
    type: 'line',
    color: '#E6E963',
    props: {
      yAxisIndex: 1,
      symbol: 'circle',
    },
  },
  spotGoodsQuantity: {
    type: 'line',
    name: '计量电量',
    color: '#18A0FB',
    props: {
      smooth: true,
      symbol: 'circle',
    },
  },
  mediumAndLongQuantity: {
    type: 'bar',
    name: '中长期电量',
    color: '#BFEBA2',
  },
  _synthesizeElectrovalence: {
    name: '综合电价',
    type: 'line',
    color: '#F6C826',
    props: {
      symbol: 'circle',
      smooth: true,
    },
  },
  mediumAndLongElectrovalence: {
    name: '中长期电价',
    type: 'line',
    color: '#30D485',
    props: {
      symbol: 'circle',
      smooth: true,
    },
  },
  wholeNetworkElectrovalence: {
    name: '用户侧结算参考点电价',
    type: 'line',
    color: '#F67E26',
    props: {
      symbol: 'circle',
      smooth: true,
    },
  },
  spotGoodsElectrovalence: {
    name: '实时节点电价',
    type: 'line',
    color: '#18A0FB',
    props: {
      smooth: true,
      symbol: 'circle',
    },
  },
};
export const chartsMap = {
  场站总览: ['synthesizeQuantity', 'synthesizeElectrovalence'],
  电量分析: ['spotGoodsQuantity', 'mediumAndLongQuantity'],
  电价分析: [
    '_synthesizeElectrovalence', //下划线 同系列名
    'mediumAndLongElectrovalence',
    'wholeNetworkElectrovalence',
    'spotGoodsElectrovalence',
  ],
};

export const yAxisMap = {
  场站总览: [
    {
      type: 'value',
      name: 'MWh',
      nameTextStyle: {
        color: getCssVariableValue('--chart-font-color'),
      },
      splitLine: {
        lineStyle: {
          color: getCssVariableValue('--chart-y-line'),
        },
      },
      axisLabel: {
        color: getCssVariableValue('--chart-font-color'),
      },
    },
    {
      type: 'value',
      name: '元/MWh',
      nameTextStyle: {
        color: getCssVariableValue('--chart-font-color'),
      },
      splitLine: {
        lineStyle: {
          color: getCssVariableValue('--chart-y-line'),
        },
      },
      axisLabel: {
        color: getCssVariableValue('--chart-font-color'),
      },
    },
  ],
  电量分析: [
    {
      type: 'value',
      name: 'MWh',
      nameTextStyle: {
        color: getCssVariableValue('--chart-font-color'),
      },
      splitLine: {
        lineStyle: {
          color: getCssVariableValue('--chart-y-line'),
        },
      },
      axisLabel: {
        color: getCssVariableValue('--chart-font-color'),
      },
    },
  ],
  电价分析: [
    {
      type: 'value',
      name: '元/MWh',
      nameTextStyle: {
        color: getCssVariableValue('--chart-font-color'),
      },
      splitLine: {
        lineStyle: {
          color: getCssVariableValue('--chart-y-line'),
        },
      },
      axisLabel: {
        color: getCssVariableValue('--chart-font-color'),
      },
    },
  ],
};
